package com.wdzl.service.impl;

import com.wdzl.dao.IpercentDao;
import com.wdzl.dao.impl.PercentDao;
import com.wdzl.pojo.Percent;
import com.wdzl.service.PercentService;
import com.wdzl.unit.Time;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class Ipercent implements PercentService {
    private final IpercentDao ipercentDao;

    public Ipercent(IpercentDao ipercentDao) {
        this.ipercentDao = ipercentDao;
    }

    @Override
    public void insert(Percent percent) {
ipercentDao.insert (percent);
    }

    @Override
    public void delete(Integer id) {
ipercentDao.delete (id);
    }

    @Override
    public void update(Percent percent) {
ipercentDao.update (percent);
    }

    @Override
    public Percent selectone(Integer id) {
        Percent selectone = ipercentDao.selectone (id);
        return selectone;
    }

    @Override
    public List<Percent> select() {
        List<Percent> select = ipercentDao.select ();
        return select;
    }

    @Override
    public void up(Percent percent) {
        ipercentDao.up (percent);
    }
@Transactional(propagation = Propagation.REQUIRED)
    @Override
    public int zhuan(String sid, String aid, float money) {
        int zhuan = ipercentDao.zhuan (sid, money);
        int shou = ipercentDao.shou (aid, money);
        return zhuan+shou;

    }
}
